import java.io.*;
import java.net.Socket;

public class TCPTransformClient {
    public static void main(String[] args) {
        try {
            Socket client = new Socket("127.0.0.1", 8888);

            OutputStream outputStream = client.getOutputStream();
            OutputStreamWriter outputStreamWriter = new OutputStreamWriter(outputStream);
            BufferedWriter bufferedWriter = new BufferedWriter(outputStreamWriter);

            InputStream inputStream = client.getInputStream();
            InputStreamReader inputStreamReader = new InputStreamReader(inputStream);
            BufferedReader bufferedReader = new BufferedReader(inputStreamReader);

            String info = "abcdefg";
            bufferedWriter.write(info);
            bufferedWriter.write("\r\n");
            bufferedWriter.flush();

            String line = bufferedReader.readLine();
            System.out.println(line);

            bufferedReader.close();
            bufferedWriter.close();
            outputStreamWriter.close();
            inputStreamReader.close();
            outputStream.close();
            inputStream.close();

            client.close();

        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
